home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 1 (Walnut Creek)
/
Aminet - June 1993 [Walnut Creek].iso
/
aminet
/
gfx
/
misc
/
fixvobj.lha
/
FixVObj.e
< prev
Wrap
Text File
|
1993-03-25
|
2KB
|
65 lines
/* FixVObj.e Swaps the signs of Z coords, so the objects will
look the same as Wavefront in Imagine and Vertex
*/
DEF pos[500]: STRING,ok,strcount,eof=-1
DEF handle=NIL
PROC main()
IF StrCmp(arg,'',1) OR StrCmp(arg,'?',2) THEN usage()
handle:=Open(arg,OLDFILE)
IF handle=NIL THEN error()
WriteF('# Vertex Wavefront file with flipped Z coords\n')
fix()
error()
ENDPROC
PROC error() /* eof or bad file */
IF handle THEN Close(handle)
CleanUp(0)
ENDPROC
PROC fix()
/* This procedure makes the actual corrections to the file */
DEF vertex=FALSE,counter
ok:=ReadStr(handle, pos)
IF ok=eof THEN error()
REPEAT
strcount:=EstrLen(pos)
IF CtrlC() THEN error()
IF pos[0]=$76 THEN vertex:=TRUE
IF vertex /* change only vertex lines */
REPEAT
DEC strcount
UNTIL pos[strcount]=$20
INC strcount
IF pos[strcount]=$2d /* change '-' to a space */
pos[strcount]:=$20
ELSE /* insert a '-' */
counter:=EstrLen(pos)
INC counter
SetStr(pos,counter)
REPEAT
pos[counter]:=pos[counter-1]
counter--
UNTIL counter=strcount
pos[strcount]:=$2d
ENDIF
vertex:=FALSE
ENDIF
WriteF('\s\n', pos)
ok:=ReadStr(handle, pos)
UNTIL ok=eof
ENDPROC
PROC usage()
WriteF('FixVObj 1.0 : Flips sign of in/out plane of Wavefront files\n')
WriteF(' For use with Vertex\n')
WriteF('\nUsage : FixVObj <file>\n\nOutput can be redirected to a file\n')
WriteF('\n(c) 1993 Danimal\n')
error()
ENDPROC